﻿using System;
using System.Windows;
using ToastNotifications;
using ToastNotifications.Lifetime;
using ToastNotifications.Messages;
using ToastNotifications.Position;

namespace NurseStation
{
    public class ToastNotification
    {
        private static ToastNotification _instance;

        private ToastNotification()
        {

        }

        public static ToastNotification GetInstance()
        {
            if (_instance == null)
            {
                _instance = new ToastNotification();
            }
            return _instance;
        }

        private Notifier Notifier = new Notifier(cfg =>
        {
            cfg.DisplayOptions.TopMost = true;
            cfg.PositionProvider = new WindowPositionProvider(
                parentWindow: Application.Current.MainWindow,
                corner: Corner.BottomRight,
                offsetX: 20,
                offsetY: 20);

            cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(
                notificationLifetime: TimeSpan.FromSeconds(3),
                maximumNotificationCount: MaximumNotificationCount.FromCount(5));

            cfg.Dispatcher = Application.Current.Dispatcher;
        });

        public void ShowInformation(string msg)
        {
            Notifier.ShowInformation(msg);
        }

        public void ShowError(string msg)
        {
            Notifier.ShowError(msg);
        }

        public void ShowSuccess(string msg)
        {
            Notifier.ShowSuccess(msg);
        }

        public void ShowWarning(string msg)
        {
            Notifier.ShowWarning(msg);
        }
    }
}
